
% Objective-C Foundation Reference Card (part 2)
% Copyright (c) 2003-2006 Dick van Oudheusden
% TeX Format

% Uncomment the following line for dvi/ps generation: tex ofc-refcard2.tex; dvips -o ofc-refcard2.ps ofc-refcard2.dvi
%\input outopt.tex

% Uncomment the following three lines for PDF generation: pdftex ofc-refcard2.tex
\pdfoutput=1
\pdfpageheight=21cm
\pdfpagewidth=29.7cm

% Font definitions
\font\bigbf=cmb12
\font\smallbf=cmb10
\font\smallrm=cmr8
\font\smalltt=cmtt8
\font\smallit=cmmi8
\font\tinyit=cmmi5

\def\cm#1#2{{\smalltt#1}\dotfill{\smallrm#2}\par}
\def\cn#1{\hfill$\lfloor$ {\smallrm#1}\par}
\def\cl#1#2{\hskip 12pt$\lfloor${\smalltt#1}\dotfill{\smallrm#2}\par}
\def\sect#1{\vskip 0.7cm \hfil{\smallbf#1}\hfil\par}
\def\para#1{{\smallit#1}\par}
\def\vsep{\vskip 6pt}

% Characters definitions
\def\bs{$\backslash$}
\def\backspace{$\leftarrow$}
\def\ctrl{{\rm\char94}\kern-1pt}
\def\enter{$\hookleftarrow$}
\def\or{\thinspace{\tinyit{or}}\thinspace}
\def\key#1{$\langle${\rm{\it#1}}$\rangle$}
\def\rapos{\char125}
\def\lapos{\char123}
\def\bs{\char92}
\def\tild{\char126}

% Three columns definitions
\parindent 0pt
%\nopagenumbers
\hoffset=-1.56cm
\voffset=-1.54cm
\newdimen\fullhsize
\fullhsize=27.9cm
\hsize=8.5cm
\vsize=19cm
\def\fullline{\hbox to\fullhsize}
\let\lr=L
\newbox\leftcolumn
\newbox\midcolumn
\output={
  \if L\lr
    \global\setbox\leftcolumn=\columnbox
    \global\let\lr=M
  \else\if M\lr
    \global\setbox\midcolumn=\columnbox
    \global\let\lr=R
  \else
    \tripleformat
    \global\let\lr=L
  \fi\fi
  \ifnum\outputpenalty>-20000
  \else
    \dosupereject
  \fi}
\def\tripleformat{
  \shipout\vbox{\fullline{\box\leftcolumn\hfil\box\midcolumn\hfil\columnbox}}
  \advancepageno}
\def\columnbox{\leftline{\pagebody}}

% Card content
% Header
%\hrule\vskip 3pt
\hfil{\bf OBJECTIVE-C FOUNDATION CLASSES}\hfil\par
\hfil{\bf REFERENCE CARD}\hfil\par
\hfil{\bf Part 2: Collections}\hfil\par
\vskip 2pt\hrule

\sect{DArray}
\para{Methods}
\cm{- init}{Init empty array}
\cm{- init :(long) length}{Init array with length}
\cm{- shallowCopy}{Copy the array}
\cm{- deepen}{Deepen a copied array} 
\cm{- shallowFree}{Free the array, not the objects}
\cm{- free}{Free the array and the objects}
\cm{- (BOOL) isValid :(long) index}{Test if index is valid}
\cm{- (long) length}{Get length of array}
\cm{- length :(long) length}{Increase length of array}
\cm{- (id) set :(long) index :(id) obj}{Set object in array}
\cm{- (id) get :(long) index}{Get object in array}
\cm{- (long) count :(id) obj}{Count occurences of object}
\cm{- (long) index :(id) obj}{Smallest index for object}
\cm{- (long) rindex :(id) obj}{Greatest index for object}
\cm{- (BOOL) has :(id) obj}{Test presence object}
\cm{- each :(SEL) sel}{Perform sel for every object}

\sect{DAvlTree}
\para{Methods}
\cm{- init :(Class) key}{Init empty tree with class key}
\cm{- shallowCopy}{Copy the AVL tree}
\cm{- deepen}{Deepen the copied AVL tree}
\cm{- free}{Free the tree and the stored objects}
\cm{- shallowFree}{Free the tree, not the objects}
\cm{- (BOOL) isEmpty}{Test for empty table}
\cm{- (long) length}{Return the number of objects}
\cm{- (id) delete :(id) key}{Delete key,object from the tree}
\cm{- get :(id) key}{Return the object related to a key}
\cm{- (BOOL) has :(id) key}{Check if the tree has a key}
\cm{- (BOOL) insert :(id) key :(id) obj}{Insert key,object}
\cm{- (DList *) keys}{Return a list with (sorted) copied keys}
\cm{- (DList *) objs}{Return a list with copied objects}
\cm{- (DList *) rkeys }{Return a list with (rev. sorted) copied keys}

\sect{DAvlIterator}
\para{Methods}
\cm{- init }{Init empty iterator}
\cm{- init :(DAvlTree *) tree}{}
\cn{Init iterator with tree, move to root}
\cm{- tree :(DAvlTree *) tree }{Set the avl tree, move to root}
\cm{- (id) first}{Get first object}
\cm{- (id) next}{Get next object}
\cm{- (id) prev}{Get previous object}
\cm{- (id) last}{Get last object}
\cm{- (id) key }{Get key in current node}
\cm{- (id) object}{Get object in current node}
\cm{- (id) object :(id) obj}{Set object in current node}

\sect{DCircle}
\para{Methods}
\cm{- init}{Init circular buffer with size 1}
\cm{- init :(long) size}{Init circular buffer with size}
\cm{- shallowCopy}{Copy the circular buffer}
\cm{- deepen}{Deepen the copied buffer}
\cm{- shallowFree}{Free the buffer, not the objects}
\cm{- free}{Free both the buffer and the objects}
\cm{- (long) size}{Return the size of the buffer}
\cm{-  size :(long) size}{Enlarge size of the buffer}
\cm{- (long) length}{Return the number of objects}
\cm{- (BOOL) isEmpty}{Test for empty buffer}
\cm{- (BOOL) isFull}{Test for full buffer}
\cm{- (BOOL) isValid :(long) index}{Check for valid index}
\cm{- (id) get :(long) index}{Get indexth object}
\cm{- (BOOL) push :(id) obj}{Push object on stack}
\cm{- (id) pop}{Pop object from stack}
\cm{- (id) tos}{Return object on top of stack}
\cm{- (BOOL) enqueue :(id) obj}{Put object in queue}
\cm{- (id) dequeue }{Get object from queue}
\cm{-  each :(SEL) sel}{Perform sel from start till last}
\cm{-  reach :(SEL) sel}{Perform sel from last till start}

\sect{DCube}
\para{Methods}
\cm{- init}{Init empty cube}
\cm{- init :(int) cols :(int) rows :(int) layers}{}
\cn{Init cube with size}
\cm{- shallowCopy}{(Copy the cube object}
\cm{- deepen}{Deepen the copied cube object}
\cm{- shallowFree}{Free the cube, not the objects}
\cm{- free}{Free the cube and the objects}
\cm{- (BOOL) isValid :(int) c :(int) r :(int) l}{}
\cn{Is row/col/layer valid?}
\cm{- (long) length}{Get length of cube}
\cm{- (int) columns}{Get number of columns}
\cm{- columns :(int) cols}{Increase number of columns}
\cm{- (int) rows}{Get number of rows}
\cm{- rows :(int) rows}{Increase number of rows}
\cm{- (int) layers}{Get number of layers}
\cm{- layers :(int) layers}{Increase number of layers}
\cm{- (id) set :(int) c :(int) r :(int) l :(id) obj}{}
\cn{Set object in cube}
\cm{- (id) get :(int) c :(int) r :(int) l}{Get object from cube}
\cm{- (long) count :(id) obj}{Count occurences of object}
\cm{- (BOOL) has :(id) obj}{Test presence object}
\cm{- each :(SEL) sel}{Perform sel for every object}

\sect{DGraph}
\para{Methods}
\cm{- init}{Init empty graph}
\cm{- init :(char *) attributes}{Init graph with attributes}
\cm{- shallowCopy}{Copy the graph object}
\cm{- deepen}{Deepen the copied graph object}
\cm{- shallowFree}{Free graph without the stored objects}
\cm{- free}{Free graph with the stored objects}
\cm{- (char *) attributes}{Return the graph attributes}
\cm{- attributes :(char *) attributes}{Set the attributes}
\cm{- (DGraphNode *) addNode :(char *) label :(char *) attr}{}
\cl{:(id) object}{Add a new node to the graph}
\cm{- (BOOL) addNode :(DGraphNode *) node}{Add node to graph}
\cm{- (DGraphEdge *) addEdge :(char *) label :(char *) attr}{}
\cl{:(double) weight :(id) object :(DGraphNode *) source}{}
\cl{:(DGraphNode *) target}{Add a new edge to the graph}
\cm{- (BOOL) addEdge :(DGraphEdge *) edge}{}
\cl{:(DGraphNode *) source :(DGraphNode *) target}{}
\cn{Add an edge to the graph}
\cm{- (BOOL) reroute :(DGraphEdge *) edge}{}
\cl{:(DGraphNode *) source :(DGraphNode *) target}{}
\cn{Reroute an existing edge}
\cm{- (DList*) shortestPath :(DGraphNode*) from}{}
\cl{:(DGraphNode*) to}{Determine shortest path in graph}
\cm{- (BOOL) hasNode :(DGraphNode *) node}{Check for a node}
\cm{- (BOOL) hasEdge :(DGraphEdge *) edge}{Check for an edge}
\cm{- (id) removeNode :(DGraphNode *) node}{}
\cn{Remove an unconnected node}
\cm{- (id) removeEdge :(DGraphEdge *) edge}{Remove an edge}
\cm{- (DListIterator *) nodes}{}
\cn{Return an iterator on the graph nodes}
\cm{- (DListIterator *) edges}{}
\cn{Return an iterator on the graph edges}
\cm{- (BOOL) toDot :(id <DTextWritable>) writer}{}
\cn{Export to dot file}

\sect{DGraphEdge}
\para{Methods}
\cm{- init}{Init empty edge}
\cm{- init :(char *) label :(double) weight :(id) object}{}
\cn{Init an edge with a label, weight and object}
\cm{- init :(char *) label :(char *) attributes}{}
\cl{:(double) weight :(id) object}{}
\cn{Init an edge with label, weight, attr. and object}
\cm{- shallowCopy}{Copy the graph edge}
\cm{- deepen}{Deepen the copied graph edge}
\cm{- shallowFree}{Free the edge without the stored object}
\cm{- free}{Free the edge and the stored object}
\cm{- (char *) name}{Return the name of the edge}
\cm{- name :(char *) name}{Set the name of the edge}
\cm{- (char *) label}{Return the label of the edge}
\cm{- label :(char *) label}{Set the label of the edge}
\cm{- (double) weight}{Return the weight of the edge}
\cm{- weight :(double) weight}{Set the weight of the edge}
\cm{- (char *) attributes}{Return the edge attributes}
\cm{- attributes :(char *) attributes}{Set the attributes}
\cm{- (id) object}{Return the stored object}
\cm{- (id) object :(id) object}{Set the stored object}
\cm{- connect :(DGraphNode *) source :(DGraphNode *) target}{}
\cn{Connect source with target by the edge}
\cm{- disconnect }{Disconnect the edge}
\cm{- (DGraphNode *) source}{Return the source node}
\cm{- (DGraphNode *) target}{Return the target node}
\cm{- reverse}{Reverse the egde}

\sect{DGraphNode}
\para{Methods}
\cm{- init}{Init empty graph node}
\cm{- init :(char *) label :(id) object}{}
\cn{Init node with label and object}
\cm{- init :(char *) label :(char *) attributes :(id) object}{}
\cn{Init node with label, attributes and object}
\cm{- shallowCopy}{Copy the graph node}
\cm{- deepen}{Deepen the copied graph node}
\cm{- shallowFree}{Free the node without the stored object}
\cm{- free}{Free the node and the stored object}
\cm{- (char *) name}{Return the name of the graph node}
\cm{- name :(char *) name}{Set the name of the node}
\cm{- (char *) label}{Return the label of the node}
\cm{- label :(char *) label}{Set the label of the node}
\cm{- (char *) attributes}{Return the attributes}
\cm{- attributes :(char *) attributes}{Set the attributes}
\cm{- (id) object}{Return the stored object}
\cm{- (id) object :(id) object}{Set the stored object}
\cm{- path}{Reset the path}
\cm{- path :(DGraphNode *) prev :(double) sum}{Set the path}
\cm{- prev}{Return the previous graph node in the path}
\cm{- (double) sum}{Return the weight sum in the path}
\cm{- (unsigned long) ingoingDegree}{Return ingoing degree}
\cm{- (unsigned long) outgoingDegree}{Return outgoing degree}
\cm{- (unsigned long) degree}{Return degree of node}
\cm{- addIngoingEdge :(DGraphEdge *) edge}{Add ingoing edge}
\cm{- (BOOL) removeIngoingEdge :(DGraphEdge *) edge}{}
\cn{Remove ingoing edge}
\cm{- addOutgoingEdge :(DGraphEdge *) edge}{Add outgoing egde}
\cm{- (BOOL) removeOutgoingEdge :(DGraphEdge *) edge}{}
\cn{Remove outgoing edge}
\cm{- (DListIterator *) ingoingEdges}{}
\cn{Return ingoing edges iterator}
\cm{- (DListIterator *) outgoingEdges}{}
\cn{Return outgoing edges iterator}

\sect{DHashTable}
\para{Methods}
\cm{- init :(Class) key}{Init table with key class}
\cm{- init :(Class) key :(ulong) size :(double) load}{}
\cn{Init table with key class, start size and load factor}
\cm{- shallowCopy}{Copy the hash table}
\cm{- deepen}{Deepen a copied hash table}
\cm{- shallowFree}{Free the table, not the objects}
\cm{- free}{Free the table and the objects}
\cm{- (long) length}{Return number of objects in table}
\cm{- (BOOL) isEmpty}{Test for empty table}
\cm{- (double) load}{Return the load factor}
\cm{- load :(double) load}{Set the load factor ($\rangle$0.0)}
\cm{- (ulong) size}{Return the size of the table}
\cm{- size :(ulong) size}{Set the size of the table}
\cm{- (BOOL) insert :(id) key :(id) obj}{Insert object in table}
\cm{- (BOOL) delete :(id) key}{Delete object from table}
\cm{- (BOOL) has :(id) key}{Test for presence in table}
\cm{- (id) get :(id) key}{Return object in table}
\cm{- each :(SEL) sel}{Perform method for every object}
\cm{- (DList *) keys}{Return new list with copied keys}
\cm{- (DList *) objects}{Return new list with copied objects}

\sect{DHashIterator}
\para{Methods}
\cm{- init}{Init empty table iterator}
\cm{- init :(DHashTable *) table}{Init table iterator}
\cm{- hashTable :(DHashTable *) table}{Set table for iterator}
\cm{- (id) first}{Go to first object in table}
\cm{- (id) next}{Go to next object in table}
\cm{- (id) prev}{Go to previous object in table}
\cm{- (id) last}{Go to last object in table}
\cm{- (id) object :(id) obj}{Set object in current node}
\cm{- (id) object}{Get object from current node}
\cm{- (id) key}{Get key for object from current node}

\sect{DList}
\para{Methods}
\cm{- init}{Init an empty list}
\cm{- shallowCopy}{Copy the list}
\cm{- deepen}{Deepen the copied list}
\cm{- shallowFree}{Free the list, not the objects}
\cm{- free}{Free the list and the objects}
\cm{- (BOOL) isEmpty}{Test for empty list}
\cm{- (long) length}{Get number elements in list}
\cm{- prepend :(id) obj}{Prepend object in list}
\cm{- append :(id) obj}{Append object in list}
\cm{- (BOOL) push :(id) obj}{Push object at end of list}
\cm{- (id) pop}{Pop the last object in the list}
\cm{- (id) tos}{Return last object in list}
\cm{- (BOOL) enqueue :(id) obj}{Enqueue the object at end of list}
\cm{- (id) dequeue}{Dequeue the first object in the list}
\cm{- insert :(long) index :(id) obj}{}
\cn{Insert object indexed in list}
\cm{- (id) set :(long) index :(id) obj}{Set the object in list}
\cm{- (id) get :(long) index}{Get the object in list}
\cm{- (DList *) get :(long) from :(long) to}{}
\cn{Get new list with ranged objects (references)}
\cm{- (id) delete :(long) index}{Delete indexed object from list}
\cm{- (DList *) delete :(long) from :(long) to}{}
\cn{Remove ranged objects to new list}
\cm{- (long) count :(id) obj}{Count the object in list}
\cm{- (long) index :(id) obj}{Smallest index for object}
\cm{- (long) rindex :(id) obj}{Biggest index for object}
\cm{- (long) replace :(id) orig :(id) repl :(long) max}{}
\cn{Replace max times every object with replace object}
\cm{- (BOOL) has :(id) obj}{Test if object in list}
\cm{- (BOOL) remove :(id) obj}{Remove object from list}
\cm{- reverse}{Reverse sequence of objects in list}
\cm{- each :(SEL) sel}{Perform method for every object}
\cm{+ (DList *) split :(char *) str :(char) sep :(int) max}{}
\cn{Split string in list of strings}
\cm{- (DText *) join :(char) sep}{Join list of strings to string}

\sect{DListIterator}
\para{Methods}
\cm{- init}{Init iterator without list}
\cm{- init :(DList *) list}{Init iterator with list}
\cm{- list :(DList *) list}{Set new list for iterator}
\cm{- (id) first}{Go to first object in list}
\cm{- (id) next}{Go to next object in list}
\cm{- (id) prev}{Go to previous object in list}
\cm{- (id) last}{Go to last object in list}
\cm{- (id) object :(id) obj}{Set object in current node}
\cm{- (id) object}{Get object from current node}

\sect{DSortedList : DList}
\para{Methods}
\cm{- init}{Init empty ascending sorted list}
\cm{- init :(Class) class :(BOOL) ascending}{Init sorted list}
\cm{- shallowFree}{Free the list, not the objects}
\cm{- free}{Free both list and stored objects}
\cm{- (BOOL) ascending}{Is the list sorted ascending}
\cm{- ascending :(BOOL) ascending}{Set sorting direction}
\cm{- (Class) class}{Return the class of the objects}
\cm{- class :(Class) class}{Set the class of the objects}
\cm{- insert :(id) object}{Insert an object, sorted}
\cm{- reverse}{Reverse the list}
\cm{+ (DSortedList *) splitSorted :(char *) str :(char) sep}{}
\cl{:(int) max}{Split string in list of sorted strings}

\sect{DTable}
\para{Methods}
\cm{- init}{Init empty table}
\cm{- init :(int) cols :(int) rows}{Init table with size}
\cm{- shallowCopy}{Copy the table}
\cm{- deepen}{Deepen the copied table}
\cm{- shallowFree}{Free the table, not the objects}
\cm{- free}{Free the table and the objects}
\cm{- (BOOL) isValid :(int) c :(int) r}{Is row/col valid?}
\cm{- (long) length}{Get length of table}
\cm{- (int) columns}{Get number of columns}
\cm{- columns :(int) cols}{Increase number of columns}
\cm{- (int) rows}{Get number of rows}
\cm{- rows :(int) rows}{Increase number of rows}
\cm{- (id) set :(int) c :(int) r :(id) obj}{Set object in table}
\cm{- (id) get :(int) c :(int) r}{Get object from table}
\cm{- (long) count :(id) obj}{Count occurences of object}
\cm{- (BOOL) has :(id) obj}{Test presence object}
\cm{- each :(SEL) sel}{Perform sel for every object}

\sect{DTree}
\para{Methods}
\cm{- init}{Init empty tree}
\cm{- shallowCopy}{Copy the tree}
\cm{- deepen}{Deepen the copied tree}
\cm{- shallowFree}{Free the tree, not the objects}
\cm{- free}{Free the tree and the objects}
\cm{- (long) length}{Return the number of objects in tree}
\cm{- (BOOL) isEmpty}{Check if the tree is empty}
\cm{- (BOOL) has :(id) obj}{Test if an object is in the tree}
\cm{- (long) count :(id) obj}{Count occurences of object}
\cm{- each :(SEL) sel}{Perform sel for each object}

\sect{DTreeIterator}
\para{Methods}
\cm{- init :(DTree *) tree}{}
\cn{Init iterator with tree, move to root}
\cm{- (id) first}{Move iterator to first node}
\cm{- (id) next}{Move iterator to next node}
\cm{- (id) prev}{Move iterator to previous node}
\cm{- (id) last}{Move iterator to last node}
\cm{- (BOOL) move :(id) obj}{Move iterator to object}
\cm{- (BOOL) isFirst}{Test for first node}
\cm{- (BOOL) isLast}{Test for last node}
\cm{- (BOOL) isRoot}{Test for root node}
\cm{- (BOOL) hasChildren}{Test for children for this node}
\cm{- (id) root}{Move to the root node}
\cm{- (id) parent}{Move to the parent node}
\cm{- (id) child}{Move to the (first) child node from parent}
\cm{- (id) object :(id) obj}{Set the object in the current node}
\cm{- (id) object}{Return the object in the current node}
\cm{- prepend :(id) obj}{Prepend new child for current parent}
\cm{- append :(id) obj}{Append new child for current parent}
\cm{- before :(id) obj}{Insert new node before current node}
\cm{- after :(id) obj}{Insert new node after current node}
\cm{- (id) remove}{Remove current node, no children}

% Footer
\vfill \hrule\smallskip
{\smallrm Version 0.7.1. This card may be freely distributed under 
the terms of the GNU general public licence\par
Copyright \copyright\ {\oldstyle 2003-2006} by Dick van Oudheusden}

% Ending
\supereject
\if L\lr \else\null\vfill\eject\fi
\if L\lr \else\null\vfill\eject\fi
\bye

% EOF
